package com.chuanke.ckfamily.service.user;

import java.util.List;
import java.util.Map;

import com.chuanke.ckfamily.dao.user.model.User;
import com.chuanke.ckfamily.service.exception.CFException;
import com.weijie.core.IBaseBiz;

public interface UserService extends IBaseBiz<User> {

	/**
	 * 查用户
	 *
	 * @param uid
	 * @return
	 */
	User findById(Long uid) throws CFException;

	/**
	 * 查找根据Token
	 *
	 * @param token
	 * @return
	 * @throws CFException
	 */
	User findByToken(String token);

	/**
	 * 根据手机查找用户
	 *
	 * @param phone
	 * @return
	 * @throws CFException
	 */
	List<User> findByPhone(Long uid, String phone) throws CFException;

	/**
	 * 用户登录
	 *
	 * @param uid
	 * @return
	 * @throws CFException
	 * @throws Exception 
	 */
	User login(Long uid) throws CFException, Exception;

	/**
	 * 根据号码查询
	 *
	 * @param userNo
	 * @return
	 * @throws CFException
	 */
	User findByUserNo(String userNo) throws CFException;

	/**
	 *
	 *
	 * @param rid
	 * @param did
	 * @return
	 * @throws CFException
	 */
	User findProxyUser(Long rid, Long did) throws CFException;

	/**
	 * 根据日期返回粉丝
	 * 如果没有传日期则返回{"newfans":[user数组];"date":timestamp}
	 * 如果传入了日期则返回{"newfans":[user数组];"updatefans":[user数组];"date":timestamp}
	 *
	 * @param uid
	 * @param date
	 * @return
	 * @throws Exception
	 */
	Map<String,Object> getFans(Long uid, String date,String page) throws CFException;

	/**
	 * 查询粉丝
	 *
	 * @param uid
	 * @param page 如果传空值，默认第一页
	 * @return
	 * @throws Exception
	 */
	List<User> getFans(Long uid, int page) throws CFException;

	/**
	 * 修改的备注
	 * @param uid  修改人
	 * @param suid 呗修改人
	 * @param remarkName 姓名
	 * @throws Exception
	 */
	Map<String, Object> updateRemarkName(Long uid ,Long suid ,String remarkName) throws CFException, Exception;

	/**
	 * 查询用户资料余额
	 * 备注：此接口涉及调用创客获取余额，所以耗时可能会较长
	 * @param uid
	 * @param tuserNo
	 * @param from 
	 * @return
	 * @throws Exception 
	 */
	Map<String, Object> getUserBalance(Long uid, String tuserNo, Integer from)throws CFException, Exception;
	/**
	 *
	 * @param uid
	 * @param tuserNo
	 * @return
	 * @throws Exception 
	 */
	Map<String, Object> getUserInfo(Long uid, String tuserNo)throws CFException, Exception;
	
	/**
	 * 检查两个用户是否是粉丝关系
	 * @param uid 申请人
	 * @param sid 被申请人
	 * @return boolean
	 */
	boolean checkIsFans(Long uid, Long sid)throws CFException;
	/**
	 * 查询家族成员资料
	 * @param uid
	 * @param tuserNo
	 * @param tid 
	 * @return
	 */
	Map<String, Object> getMemberInfo(Long uid, String tuserNo, String tid)throws CFException;

	Map<String, Object>  formatUserBalanceCode(User user, User tuser,Map<String, Object> result,Integer from) throws CFException;

	Map<String, Object>  formatMemberInfoCode(User user, User tuser, Map<String, Object> result)throws CFException;

	List<User> searchUser(Map<String, Object> Map);
	/**
	 * 首页搜索
	 * @param uid
	 * @param keyword
	 * @return
	 */
	Map<String, Object>  homeSearch(Long uid, String keyword) throws Exception;
	/**
	 * 查询我的上级
	 * @param uid
	 * @return
	 */
	User findBySuperId(Long uid)throws CFException;

	/**
	 * 检查用户粉丝加载
	 * @param uid 用户id
	 */
	void checkUserFans(Long uid);

	/**
	 * 查找所有用户id
	 * @return 用户id集合
	 */
	List<Long> findAllUserId();

}